package com.icss.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import com.icss.dao.PurchaseDao;
import com.icss.entity.Purchase;

@Controller
public class purchase_controller {
	@Autowired PurchaseDao dao;
	@RequestMapping("insertbuyer")
	public String fun1(int buyer_id,String goods_name,int goods_price,int goods_num){
		int r=dao.addpurchases( buyer_id, goods_name,  goods_price, goods_num);
		return "redirect:showbuyer.do";
		
	}
	@RequestMapping("showbuyer")
	public String fun2(ModelMap map){
		List<Purchase> list=dao.buyer();
		map.addAttribute("buyerList", list);
		
		return "purchaseManage";
		
	}
	@RequestMapping("updatep")
	public String fun4(ModelMap map,Integer goods_id){
		List<Purchase> list=dao.updatep(goods_id);
		map.addAttribute("buyerList", list);
		
		return "updatepurchase";
		
	}
	@RequestMapping("deletep")
	public String fun3(ModelMap map,Integer goods_id){
		int r=dao.deletep(goods_id);
		return "redirect:showbuyer.do";
		
	}
	@RequestMapping("updatepurchase")
	public String fun5(ModelMap mp,String goods_name,int goods_num,int goods_price ,int goods_id){
		int r=dao.updatepurchase(goods_name, goods_num, goods_price,goods_id);
		return "redirect:showbuyer.do";
	}
}
